package org.example.controller;

import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @PostMapping("/login")
    public Map<String, Object> login(@RequestBody @NonNull Map<String, String> user) {
        log.info("login 接收参数:{}", user);
        if(ObjectUtils.isEmpty(user)) {
            return appReturn(1100, "用户名或密码不能为空", -1);
        }
        return null;
    }

    public Map<String, Object> appReturn(Integer code, String msg, Object data) {
        Map<String, Object> res = new HashMap<>();
        res.put("code", code);
        res.put("msg", msg);
        res.put("data", data);
        return res;
    }


}
